package com.nanhai.buddhist.college.module.study.dal.mysql.timetable;

import java.util.*;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.module.study.dal.dataobject.timetable.ClassTimetableDO;
import org.apache.ibatis.annotations.Mapper;
import com.nanhai.buddhist.college.module.study.controller.admin.timetable.vo.*;

/**
 * 课程 Mapper
 *
 * @author xqenzo@163.com
 */
@Mapper
public interface ClassTimetableMapper extends BaseMapperX<ClassTimetableDO> {

    default PageResult<ClassTimetableDO> selectPage(ClassTimetablePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClassTimetableDO>()
                .eqIfPresent(ClassTimetableDO::getCollegeId, reqVO.getCollegeId())
                .eqIfPresent(ClassTimetableDO::getStudyTimeId, reqVO.getStudyTimeId())
                .eqIfPresent(ClassTimetableDO::getWeekId, reqVO.getWeekId())
                .eqIfPresent(ClassTimetableDO::getClassesId, reqVO.getClassesId())
                .eqIfPresent(ClassTimetableDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(ClassTimetableDO::getRoomId, reqVO.getRoomId())
                .eqIfPresent(ClassTimetableDO::getTeacherId, reqVO.getTeacherId())
                .eqIfPresent(ClassTimetableDO::getType, reqVO.getType())
                .eqIfPresent(ClassTimetableDO::getClassMode, reqVO.getClassMode())
                .betweenIfPresent(ClassTimetableDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ClassTimetableDO::getCreateTime));
    }

    default List<ClassTimetableDO> selectList(ClassTimetableExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ClassTimetableDO>()
                .eqIfPresent(ClassTimetableDO::getCollegeId, reqVO.getCollegeId())
                .eqIfPresent(ClassTimetableDO::getStudyTimeId, reqVO.getStudyTimeId())
                .eqIfPresent(ClassTimetableDO::getWeekId, reqVO.getWeekId())
                .eqIfPresent(ClassTimetableDO::getClassesId, reqVO.getClassesId())
                .eqIfPresent(ClassTimetableDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(ClassTimetableDO::getRoomId, reqVO.getRoomId())
                .eqIfPresent(ClassTimetableDO::getTeacherId, reqVO.getTeacherId())
                .eqIfPresent(ClassTimetableDO::getType, reqVO.getType())
                .eqIfPresent(ClassTimetableDO::getClassMode, reqVO.getClassMode())
                .betweenIfPresent(ClassTimetableDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ClassTimetableDO::getCreateTime));
    }

}
